<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>数据源管理</title>
        <%@include file="/WEB-INF/jsp/include.jsp"%>
        <script type="text/javascript">

            $(function() {
                $("#saveDS").on("click", function() {
                    submit_add();
                });

                //保存增加的数据
                function submit_add() {
                    if (!validform("dsForm")) {
                        return;
                    } 

                    $("#dsForm").ajaxSubmit({
                        type: "POST",
                        //url:'${path}/system/ds/save',
                        url:'${path}/system/ds/save',
                        dataType: "json",
                        success : function callback(data) {
                            var analyMsg = data;
                            if (analyMsg.code != '0000') {
                                $.alert('add', 'error', '数据源');
                            } else {
                                $.alert('add', 'info', '数据源');
                            }
                        },
                        error : function(data, textstatus) {
                            $.alert('add', 'error', '数据源');
                        }
                    });
                }
            });
        </script>
    </head>

    <body style="margin:0px; padding:0px;">
        <div class="easyui-layout" fit="true">
            <div id="AddDlgDiv" align="center"  style="margin:5px; padding:5px;">
                <form id="dsForm" method="post" >
                    <table class="f_table" cellspacing="1">
                        <tr>
                            <td align="right" class="s_bg" style="width:160px;">数据源名称：
                            </td>
                            <td align="left" style="width: 200px;">
                                <input type="text" id="dsName" name="dsName" style="width: 200px;" class="easyui-validatebox" data-options="required:true"/>
                            </td>
                            <td align="right" class="s_bg" style="width: 160px;">数据库类型：
                            </td>
                            <td align="left" style="width: 200px;">
                                <select id="dbType" name="dbType" class="easyui-combobox" data-options="panelWidth:160" style="width: 200px;">
                                    <option value="Oracle">Oracle</option>
                                    <option value="DB2">DB2</option>
                                    <option value="MySQL">MySQL</option>
                                    <option value="SQLServer">SQLServer</option>
                                    <option value="Sybase">Sybase</option>
                                    <option value="ODBC">ODBC</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" class="s_bg">数据库地址：
                            </td>
                            <td align="left">
                                <!-- data-options="validType:'url ip'" -->
                                <input type="text" id="dbURL" name="dbURL" style="width: 200px;" class="easyui-validatebox" data-options="required:true"/>
                            </td>
                            <td align="right" class="s_bg">数据库端口：
                            </td>
                            <!-- port's value between 0-65535  -->
                            <td align="left">
                                <input type="text" id="dbPort" name="dbPort" style="width: 200px;" class="easyui-validatebox" data-options="required:true,validType:'port[5]'"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" class="s_bg">服务名/数据库名 ：
                            </td>
                            <td align="left">
                                <input type="text" id="dbName" name="dbName" style="width: 200px;" class="easyui-validatebox" data-options="required:true,validType:'specialCharacters[30]'"/>
                            </td>
                            <td align="right" class="s_bg">数据库用户名 ：
                            </td>
                            <td align="left">
                                <input type="text" id="dbUser" name="dbUser" style="width: 200px;" class="easyui-validatebox" data-options="required:true,validType:'specialCharacters[30]'"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" class="s_bg">数据库密码 ：
                            </td>
                            <td align="left">
                                <input type="text" id="dbPWD" name="dbPWD" style="width: 200px;" class="easyui-validatebox" data-options="required:true"/>
                            </td>
                            <td align="right" class="s_bg">数据库最小连接 ：
                            </td>
                            <td align="left" style="width: 200px;">
                                <input type="text" id="minConn" name="minConn" style="width: 200px;" class="easyui-validatebox" data-options="required:true,validType:'posInteger', length:[0,2]"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" class="s_bg">数据库最大连接 ：
                            </td>
                            <td align="left">
                                <input type="text" id="maxConn" name="maxConn" style="width: 200px;" class="easyui-validatebox" data-options="required:true,validType:'posInteger', length:[0,2]"/>
                            </td>
                            <td align="right" class="s_bg"></td>
                        </tr>
                    </table>
                </form>
                <div align="center" style="margin-top: 15px;">
                    <a id="saveDS" href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok">确定</a>
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="closeLayer();">取消</a>
                </div>
            </div>
        </div>
    </body>
</html>
